//
//  YGUploadAnalyticsEntity.m
//  YGMobile
//
//  Created by 袁斌 on 2017/2/27.
//  Copyright © 2017年 Elephants Financial Service. All rights reserved.
//

#import "YGUploadAnalyticsEntity.h"
#import "YSAppInfo.h"
#import <AFNetworking/AFNetworking.h>
#import <YTXUtilCategory/SSNetworkInfo.h>
#import "YSUserManager.h"
#import "EncryptHelper.h"

@implementation YGUploadAnalyticsEntity

- (NSString *)token
{
    return objectOrEmptyStr([YSUserManager sharedManager].currentUser.token);
}

- (NSString *)platform
{
      return @"ios";
}

- (NSString *)channel
{
    if (!_channel) {
        _channel = [YSAppInfo marketId];
    }
    return _channel;
}

- (NSString *)user_status
{
//    return [NSString stringWithFormat:@"%@",[YSUserManager sharedManager].currentUser.userType];
    return @"";
}

- (NSString *)os
{
    UIDevice *device = [UIDevice currentDevice];
    return device.model;
}

- (NSString *)os_version
{
    UIDevice *device = [UIDevice currentDevice];
    return device.systemVersion;
}

- (NSString *)app
{
    if (!_app) {
        _app = [YSAppInfo bundleId];
    }
    return _app;
}

- (NSString *)describe
{
    return @"";
}

- (NSString *)version
{
    if (!_version) {
        _version = [YSAppInfo appVersion];
    }
    return _version;
}

- (NSString *)time
{
    return [NSString stringWithFormat:@"%f",[[NSDate now] timeIntervalSince1970]];
}

- (NSString *)identify
{
    if (!_identify) {
        _identify = [YSAppInfo deviceUUID];
    }
    return _identify;
}

- (NSString *)type
{
    return @"0";
}

- (NSString *)description
{
    return @"";
}

-(NSString *)ip
{
    return objectOrEmptyStr([SSNetworkInfo currentIPAddress]);
}

- (NSString *)company
{
    return @"yg";
}

- (NSString *)net
{
//    return [YSAppInfo networkType];
    return @"";
}

- (NSString *)user
{
    NSString *phoneNumber = objectOrEmptyStr([YSUserManager sharedManager].currentUser.mobile);
    BOOL isBindPhone = [phoneNumber isTel];
    if (isBindPhone) {//绑手机号了
        return phoneNumber;
    } else {
        return objectOrEmptyStr([YSUserManager sharedManager].currentUser.username);
    }
}

- (NSString *)checksum
{
    return [EncryptHelper checkSumByMD5Encrypt];
}

@end
